import { Component, OnInit } from '@angular/core';
import { RegisterService } from '../service/register.service';
import { User } from '../models/user';

@Component({
  selector: 'app-register',
  templateUrl: './register.component.html',
  styleUrls: ['./register.component.css']
})
export class RegisterComponent implements OnInit {
  newUser: User = new User();
  constructor(private regsiterService: RegisterService) { }

  ngOnInit() {
  }

  onSubmit() {
    this.regsiterService.sendUser(this.newUser).subscribe(
      data => {
        this.newUser = new User();
      },
      error => console.log(error)
    );
  }

}
